package com.zige.zige.utils;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;

/**
 * 共享配置工具类
 * Created by SONY-SONG on 2015/3/23.
 */
public class SharedPreferencesUtils {
    /**
     * shared_preference文件名
     */
    private static final String sharedPreferenceName="littlezebra_pref";
    private static int mode= Context.MODE_PRIVATE;

    public static final String keep_login_state="keep_login_state";
    public static final String keep_login_userCount="keep_login_userCount";
    public static final String keep_login_password="keep_login_password";

    public static final String first_enter = "first_enter";

    public static final String gesture_toggle="gesture_toggle";
    public static final String dayFirst="dayFirst";



    public static final String user_safetyLockPassword="user_safetyLockPassword";
    public static final String user_loaclheadimage="user_loaclheadimage";


    public static final String isplayvoice="isplayvoice";
    public static final String qiniu_imageUrl="qiniu_imageUrl";

    public static final String update_appprompt="update_Appprompt";
    public static final String voice_loading="voice_loading";

    public static final String main_registe_operate_guide="main_registe_operate_guide";
    public static final String videodetails_operate_guide="videodetails_operate_guide";
    public static final String user_complete_infomation="user_complete_infomation";
    public static final String user_isWatch="user_isWatch";







    public static Object getValue(Context c,String key,Object value){
        SharedPreferences sp=c.getSharedPreferences(sharedPreferenceName,mode);
        if(value instanceof Boolean)
            return sp.getBoolean(key,(Boolean)value);
        else if(value instanceof Integer)
            return sp.getInt(key,(Integer)value);
        else if(value instanceof Float)
            return sp.getFloat(key,(Float)value);
        else if(value instanceof Long)
            return sp.getLong(key,(Long)value);
        else if(value instanceof String)
            return sp.getString(key,(String)value);
        else
            return null;
    }

    public static boolean saveValue(Context c,String key,Object value){
        SharedPreferences sp=c.getSharedPreferences(sharedPreferenceName,mode);
        Editor ed=sp.edit();
        if(value instanceof Boolean)
            return ed.putBoolean(key,(Boolean)value).commit();
        else if(value instanceof Integer)
            return ed.putInt(key,(Integer)value).commit();
        else if(value instanceof Float)
            return ed.putFloat(key,(Float)value).commit();
        else if(value instanceof Long)
            return ed.putLong(key,(Long)value).commit();
        else if(value instanceof String)
            return ed.putString(key,(String)value).commit();
        else
            return false;
    }


}
